home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / s342q08.lha / netlist.c < prev    next >
C/C++ Source or Header  |  1995-07-30  |  4KB  |  161 lines

  1. /*
  2.  * Generate the NetLink Listing of Shared Rooms.
  3.  */
  4.  
  5. #include "ctdl.h"       /*
  6.                          * header file
  7.                          */
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <stdlib.h>
  11. #include <math.h>
  12. #include <ctype.h>
  13. #include <time.h>
  14. #include <proto/exec.h>
  15. #include <dos/dos.h>
  16. #include <pragmas/dos_pragmas.h>
  17. #include "exec/memory.h"
  18. #include "exec/ports.h"
  19. #include "exec/exec.h"
  20.  
  21. /*
  22.  *                              contents
  23.  *
  24.  *      crashout()              irrecoverable error
  25.  *      main()                  Main controller for this program
  26.  *      openFile()              opens a .sys file
  27.  */
  28.  
  29. extern rTable *roomTab;           /*
  30.  
  31.                                    * RAM index of rooms
  32.                                    */
  33. extern CONFIG cfg;                /*
  34.  
  35.                                    * A buncha variables
  36.                                    */
  37. extern FILE *netfl;
  38. extern NetBuffer netBuf;
  39. extern NetTable *netTab;
  40. extern VirtualRoom *VRoomTab;
  41. extern char VirtualInUse;
  42. extern VirtNet *VirtNetList;
  43. extern int thisNet,
  44.           VirtSize,
  45.           VNetSize;
  46. FILE     *netLog;
  47.  
  48. void CheckNet(int i, int roomSlot);
  49. void CheckVirt(int TheVirt, int NetRover);
  50.  
  51. /*
  52.  * crashout()
  53.  *
  54.  * This function handles an irrecoverable error.
  55.  */
  56. void
  57. crashout(str)
  58.   char     *str;
  59. {
  60.   exit(printf(str));
  61. }
  62.  
  63. /*
  64.  * main()
  65.  *
  66.  * This is the main controller.
  67.  */
  68. int       main(int, char **);
  69. int
  70. main(argc, argv)
  71.   int       argc;
  72.   char    **argv;
  73. {
  74.   SYS_FILE  netFile;
  75.   int       Index, NetRover;
  76.   cfg.weAre = UTILITY;
  77.   if (readSysTab(FALSE, TRUE))
  78.     {
  79.       mvToHomeDisk(&cfg.homeArea);
  80.       makeSysName(netFile, "ctdlnet.sys", &cfg.netArea);
  81.       openFile(netFile, &netfl);
  82.       initNetBuf(&netBuf);
  83.       printf("#!netlinks %s %s\n", cfg.codeBuf + cfg.nodeName, cfg.codeBuf + cfg.nodeId);
  84.       for (Index = AIDEROOM + 1;        /*
  85.                                          * First 3 never shared
  86.                                          */
  87.            Index < MAXROOMS; Index++)
  88.         {
  89.           if (roomTab[Index].rtflags.INUSE &&
  90.               roomTab[Index].rtflags.SHARED)
  91.             {
  92.               printf(" room=%20s\n", roomTab[Index].rtname);
  93.               for( NetRover = 0; NetRover < cfg.netSize; NetRover++)
  94.                 {
  95.                 CheckNet(NetRover, Index);
  96.                 };
  97.             };
  98.         };
  99.     };
  100.   VirtInit();
  101.   if (VirtualInUse)
  102.     {
  103.       for (Index = 0; Index < VirtSize; Index++)
  104.         {
  105.           if (strLen(VRoomTab[Index].vrName) != 0)
  106.             {
  107.               printf(" room=%20s", VRoomTab[Index].vrName);
  108.               for (NetRover = 0; NetRover < cfg.netSize; NetRover++)
  109.                  CheckVirt(Index, NetRover);
  110.             };
  111.         };
  112.     };
  113.   printf("end_data\n");
  114. }
  115.  
  116. /*
  117.  * CheckNet()
  118.  *
  119.  * This checks to see if the given room is shared with this node and does
  120.  * the requisite print.
  121.  */
  122. void CheckNet(int i, int roomSlot)
  123. {
  124.     int j;
  125.  
  126.     if (netTab[i].ntflags.in_use)
  127.       {
  128.       for (j = 0; j < SHARED_ROOMS; j++)
  129.         {
  130.         if (isSharedRoom(i, j))
  131.           {
  132.           if (netTabRoomSlot(i, j) == roomSlot &&
  133.               roomTab[roomSlot].rtgen == netGen(i, j))
  134.             {
  135.             getNet(i, &netBuf);
  136.             printf(" share=%20s %s\n", netBuf.netName, netBuf.netId);
  137.             return;
  138.             }
  139.           }
  140.         }
  141.       }
  142. }
  143.  
  144. /*
  145.  * CheckVirt()
  146.  *
  147.  * This processes a virtual room.
  148.  */
  149. void CheckVirt(int TheVirt, int NetRover)
  150. {
  151.     int i;
  152.     for (i = 0; i < VIRT_LIMIT; i++) {
  153.         if (VirtNetList[NetRover].VirtList[i].WhichVirt == TheVirt) {
  154.             getNet(NetRover, &netBuf);
  155.             if (netBuf.nbflags.in_use) {
  156.                 printf(" share=%s %s\n", netBuf.netName, netBuf.netId);
  157.             }
  158.         }
  159.     }
  160. }
  161.